Skip to content

fix: Shift+Click on column header now triggers multi-column sort#543

Closed
datlechin wants to merge 4 commits intomainfrom
fix/shift-click-multi-column-sort
Closed

fix: Shift+Click on column header now triggers multi-column sort#543
datlechin wants to merge 4 commits intomainfrom
fix/shift-click-multi-column-sort

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Fixes the multi-column sort part of #541.

Root cause: NSTableView swallows Shift+Click on column headers — the sortDescriptorsDidChange delegate is never called when Shift is held. The existing multi-sort logic in handleSort was correct but unreachable.

Fix: Added SortableTableHeaderView (NSTableHeaderView subclass) that intercepts mouseDown when Shift is held, identifies the clicked column, and routes directly to the coordinator's multi-sort handler — bypassing NSTableView's broken Shift+Click behavior.

Changes:

  • KeyHandlingTableView.swift — Added SortableTableHeaderView class
  • DataGridView.swift — Installed custom header view on table creation
  • DataGridView+Sort.swift — Added handleShiftClickSort entry point for the header view

Test plan

  • Click a column header → sorts by that column (single sort, unchanged behavior)
  • Shift+Click another column header → adds it as secondary sort (e.g., ORDER BY name ASC, id ASC)
  • Shift+Click the same column again → removes it from multi-sort
  • Verify sort indicators show priority numbers (e.g., name 1▲, id 2▼)
  • Normal click after multi-sort → resets to single-column sort

@datlechin datlechin closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant